package com.yxkj.syh.app.huarong.data_center.model;

import com.syh.app.basic.utils.net.ApiObserver;
import com.yxkj.syh.app.huarong.util.RetrofitHelper;
import com.trello.rxlifecycle2.LifecycleTransformer;
import com.yxkj.syh.app.huarong.api.PaymentApi;

import java.util.Map;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * 创建者：SYH
 * 时间：2020/5/22 13:57
 * 编辑者：SYH、
 * 标签：
 * 补充说明：
 */
public class PaymentModel {
    private static PaymentModel paymentModel;

    private PaymentModel() {
    }

    public static PaymentModel getPaymentModel() {
        if (paymentModel == null) paymentModel = new PaymentModel();
        return paymentModel;
    }

    private PaymentApi getAuthApi() {
        return RetrofitHelper.createApi(PaymentApi.class);
    }

    public void paymentMethodList(long id,LifecycleTransformer transformer, ApiObserver apiObserver) {
        getAuthApi().paymentMethodList(id).compose(transformer).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread()).subscribe(apiObserver);
    }

    public void editPayment(Map<String,Object> payment, LifecycleTransformer transformer, ApiObserver apiObserver) {
        getAuthApi().editPayment(payment).compose(transformer).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
                .subscribe(apiObserver);
    }

    public void paymentDetail(long id, LifecycleTransformer transformer, ApiObserver apiObserver) {
        getAuthApi().paymentDetail(id).compose(transformer).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
                .subscribe(apiObserver);
    }

}
